﻿using EmoneyWeiXinCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EmoneyWeiXinDAL
{
    public class MenuReportMergeDAL
    {
        public void Insert(string menuType, List<string> newsReportId, string weixinId)
        {


            string sql = string.Format("DELETE MenuReportMerge where weixinId={0} AND menuType='{1}'", weixinId, menuType);
            if (newsReportId.Count > 0)
            {
                sql += "INSERT INTO MenuReportMerge(weixinId,menuType,newsReportId,UpdateTime)";
                sql += string.Format("SELECT '{0}','{1}','{2}',GETDATE()", weixinId, menuType, newsReportId[0]);
                for (int i = 1; i < newsReportId.Count; i++)
                {
                    sql += string.Format(" union all SELECT '{0}','{1}','{2}',GETDATE()", weixinId, menuType, newsReportId[i]);
                }
               
            }
            SQLHelper.ExecuteNonQuery(Config.EmoneyWeiXin, System.Data.CommandType.Text, sql);
        }
    }
}
